package com.cloud.redisson.config;

import cn.hutool.core.io.resource.ResourceUtil;
import org.redisson.Redisson;
import org.redisson.api.RedissonClient;
import org.redisson.config.Config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.io.IOException;

/**
 * @author zhaoyangfu - 2020/7/23 11:08
 */
@Configuration
public class RedissonConfig {

    @Bean
    public Config config() throws IOException {
        return Config.fromYAML(ResourceUtil.readUtf8Str("redisson.yml"));
    }

    @Bean
    public RedissonClient redisson(Config config) {
        return Redisson.create(config);
    }
}
